<template>
  <div class="button-properties">
    <el-form label-position="top">
      <el-form-item label="按钮文本">
        <el-input
          v-model="properties.text"
          placeholder="请输入按钮文本"
          @change="updateProperties" />
      </el-form-item>
      
      <el-form-item label="按钮类型">
        <el-select
          v-model="properties.type"
          placeholder="请选择按钮类型"
          @change="updateProperties">
          <el-option label="主要按钮" value="primary" />
          <el-option label="成功按钮" value="success" />
          <el-option label="警告按钮" value="warning" />
          <el-option label="危险按钮" value="danger" />
          <el-option label="信息按钮" value="info" />
          <el-option label="默认按钮" value="default" />
        </el-select>
      </el-form-item>
      
      <el-form-item label="按钮尺寸">
        <el-select
          v-model="properties.size"
          placeholder="请选择按钮尺寸"
          @change="updateProperties">
          <el-option label="大" value="large" />
          <el-option label="默认" value="default" />
          <el-option label="小" value="small" />
        </el-select>
      </el-form-item>
    </el-form>
  </div>
</template>

<script setup>
import { ref, watch } from 'vue'

const props = defineProps({
  value: {
    type: Object,
    default: () => ({
      text: '按钮',
      type: 'primary',
      size: 'default'
    })
  }
})

const emit = defineEmits(['update'])

const properties = ref({ ...props.value })

watch(() => props.value, (newVal) => {
  properties.value = { ...newVal }
}, { deep: true })

const updateProperties = () => {
  emit('update', { ...properties.value })
}
</script> 